﻿using AutoMapper;
using Common.Security;
using Ecommerce.Common;
using Ecommerce.DTO;
using Ecommerce.EntityFrameworkCore;
using Ecommerce.tbCommodity;
using Ecommerce.tbUser;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace Ecommerce.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class tbUserController: IServices
    {
        private readonly EcommerceDbContext _context;
        public tbUserController(EcommerceDbContext context)
        {
            _context = context;
        }
        [HttpGet]
        public int LoginUser(string phone, string pwd/*, string code*/)
        {
            pwd = Md5.GetMd5(pwd);
            int i = _context.users.Where(s => s.UserPhone.Equals(phone) && s.UserPwd.Equals(pwd)).Count();
            if (i > 0)
            {
                return 1;
            }
            else
            {
                return 2;
            }
        }
    }
}
